package cn.ztq.test0614;

import android.media.MediaPlayer;
import android.media.audiofx.DynamicsProcessing;
import android.media.audiofx.Equalizer;
import android.media.audiofx.Virtualizer;
import android.os.Bundle;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.blankj.utilcode.util.LogUtils;

public class EQActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.eq_layout);
        MediaPlayer mediaPlayer = MediaPlayer.create(this, R.raw.notice);
        int audioSessionId = mediaPlayer.getAudioSessionId();
        Equalizer equalizer = new Equalizer(0, audioSessionId);
        equalizer.setEnabled(true);


//        Virtualizer virtualizer=new Virtualizer(0,audioSessionId);
//
//        virtualizer.setStrength();
////        DynamicsProcessing.Eq
//        DynamicsProcessing.Limiter

// 获取均衡器支持的频段数量
        short numberOfBands = equalizer.getNumberOfBands();
        LogUtils.d("numberOfBands\n"+numberOfBands);

// 获取每个频段的增益范围（最小增益和最大增益）
        short minEQLevel = equalizer.getBandLevelRange()[0];
        short maxEQLevel = equalizer.getBandLevelRange()[1];
        LogUtils.d("minEQLevel\n"+minEQLevel);
        LogUtils.d("maxEQLevel\n"+maxEQLevel);
// 设置第一个频段的增益
        equalizer.setBandLevel((short) 0, (short) (maxEQLevel / 2)); // 调节第一个频段

    }
}
